package com.ruoyi.production.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.production.mapper.RegulatorReturnMapper;
import com.ruoyi.production.domain.RegulatorReturn;
import com.ruoyi.production.service.IRegulatorReturnService;

/**
 * 调节剂退回Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-19
 */
@Service
public class RegulatorReturnServiceImpl implements IRegulatorReturnService
{
    @Autowired
    private RegulatorReturnMapper regulatorReturnMapper;

    /**
     * 查询调节剂退回
     *
     * @param regulagorReturnId 调节剂退回ID
     * @return 调节剂退回
     */
    @Override
    public RegulatorReturn selectRegulatorReturnById(Long regulagorReturnId)
    {
        return regulatorReturnMapper.selectRegulatorReturnById(regulagorReturnId);
    }

    /**
     * 查询调节剂退回列表
     *
     * @param regulatorReturn 调节剂退回
     * @return 调节剂退回
     */
    @Override
    public List<RegulatorReturn> selectRegulatorReturnList(RegulatorReturn regulatorReturn)
    {
        return regulatorReturnMapper.selectRegulatorReturnList(regulatorReturn);
    }

    /**
     * 新增调节剂退回
     *
     * @param regulatorReturn 调节剂退回
     * @return 结果
     */
    @Override
    public int insertRegulatorReturn(RegulatorReturn regulatorReturn)
    {
        regulatorReturn.setCreateTime(DateUtils.getNowDate());
        return regulatorReturnMapper.insertRegulatorReturn(regulatorReturn);
    }

    /**
     * 修改调节剂退回
     *
     * @param regulatorReturn 调节剂退回
     * @return 结果
     */
    @Override
    public int updateRegulatorReturn(RegulatorReturn regulatorReturn)
    {
        regulatorReturn.setUpdateTime(DateUtils.getNowDate());
        if(regulatorReturn.getApproval()==1) {
            regulatorReturnMapper.updateRegulatorAmount(regulatorReturn);
            return regulatorReturnMapper.updateRegulatorReturn(regulatorReturn);
        }
        else
            return regulatorReturnMapper.updateRegulatorReturn(regulatorReturn);
    }

    /**
     * 批量删除调节剂退回
     *
     * @param regulagorReturnIds 需要删除的调节剂退回ID
     * @return 结果
     */
    @Override
    public int deleteRegulatorReturnByIds(Long[] regulagorReturnIds)
    {
        return regulatorReturnMapper.deleteRegulatorReturnByIds(regulagorReturnIds);
    }

    /**
     * 删除调节剂退回信息
     *
     * @param regulagorReturnId 调节剂退回ID
     * @return 结果
     */
    @Override
    public int deleteRegulatorReturnById(Long regulagorReturnId)
    {
        return regulatorReturnMapper.deleteRegulatorReturnById(regulagorReturnId);
    }

    /**
     * 获取调节剂类型下拉框
     *
     * @param
     * @return 结果
     */
    @Override
    public List<RegulatorReturn> getRegulatorType(){
        return regulatorReturnMapper.getRegulatorType();
    }

    /**
     * 获取调节剂名称下拉框
     *
     * @param
     * @return 结果
     */
    @Override
    public List<RegulatorReturn> getRegulatorName(){
        return regulatorReturnMapper.getRegulatorName();
    }

    /**
     * 获取用户下拉框
     *
     * @param
     * @return 结果
     */
    @Override
    public List<RegulatorReturn> getUserName(){
        return regulatorReturnMapper.getUserName();
    }

    /**
     * 获取有效含量下拉框
     *
     * @param regulatorNameId
     * @return 结果
     */
    @Override
    public List<String> getContent(Long regulatorNameId){
        return regulatorReturnMapper.getContent(regulatorNameId);
    }

    /**
     * 获取购自公司下拉框
     *
     * @param regulatorNameId
     * @return 结果
     */
    @Override
    public List<String> getOriginCompany(Long regulatorNameId){
        return regulatorReturnMapper.getOriginCompany(regulatorNameId);
    }
}
